//
//  NavigateItemActivity.m
//  飞波
//
//  Created by Leo on 9/16/11.
//  Copyright 2011 Feibo Inc. All rights reserved.
//

#import "NavigateItemActivity.h"

@implementation UIViewController (NavigateItemActivity)
- (void)addActivityOnNavigate:(NSString *)text labelWidth:(CGFloat)w
{
	UILabel * label =  [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, w, 30)] autorelease];
	UIActivityIndicatorView * activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
	activity.center = CGPointMake(w - 15, 15);
	[activity startAnimating];
	[label addSubview:activity];
	[activity release];
	[label setText:text];
	[label setBackgroundColor:[UIColor clearColor]];
	[label setTextAlignment:UITextAlignmentCenter];
	[label setTextColor:[UIColor whiteColor]];
	[label setFont:[UIFont boldSystemFontOfSize:20]];
	self.navigationItem.titleView = label;
}

- (void)removeActivityOnNavigate:(NSString *)t
{
	if (self.navigationItem.titleView) {
		[self.navigationItem.titleView removeFromSuperview];
	}
	self.navigationItem.titleView = nil;
	self.title = t;
}
@end
